package com.edu.exam.entity.classmanagement.administrative;

// ClassStatus枚举现在在同一个包中，无需import
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 行政班级实体类
 * 所属模块：F-05 行政班级管理模块
 * 对应数据库表：administrative_class
 *
 * 管理行政班级的基本信息，包括班级编码、名称、类型、状态等。
 * 支持行政班级的创建、查询、更新和状态管理。
 * 关联专业、年级、班主任等关键信息，提供行政班级的完整视图。
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Table(name = "administrative_class")
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class AdministrativeClass {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank(message = "班级编码不能为空")
    @Size(max = 50, message = "班级编码长度不能超过50个字符")
    @Column(name = "class_code", unique = true, nullable = false, length = 50)
    private String classCode;

    @NotBlank(message = "班级名称不能为空")
    @Size(max = 100, message = "班级名称长度不能超过100个字符")
    @Column(name = "class_name", nullable = false, length = 100)
    private String className;

    @NotNull(message = "所属专业不能为空")
    @Column(name = "major_id", nullable = false)
    private Long majorId;

    @NotNull(message = "入学年份不能为空")
    @Column(name = "enrollment_year", nullable = false)
    private Integer enrollmentYear;

    @NotNull(message = "计划人数不能为空")
    @Column(name = "planned_count", nullable = false)
    private Integer plannedCount;

    @Column(name = "actual_count", nullable = false)
    @Builder.Default
    private Integer actualCount = 0;

    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false, length = 20)
    @Builder.Default
    private ClassStatus status = ClassStatus.ACTIVE;

    @Size(max = 50, message = "班主任姓名长度不能超过50个字符")
    @Column(name = "advisor", length = 50)
    private String advisor;

    @Size(max = 20, message = "班主任联系方式长度不能超过20个字符")
    @Column(name = "advisor_contact", length = 20)
    private String advisorContact;

    @Size(max = 500, message = "班级描述长度不能超过500个字符")
    @Column(name = "description", length = 500)
    private String description;

    @Column(name = "deleted", nullable = false)
    @Builder.Default
    private Boolean deleted = false;

    @CreatedDate
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;

    @LastModifiedDate
    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime;

    @Size(max = 50, message = "创建人长度不能超过50个字符")
    @Column(name = "create_by", length = 50)
    private String createBy;

    @Size(max = 50, message = "更新人长度不能超过50个字符")
    @Column(name = "update_by", length = 50)
    private String updateBy;
}